/// author stevenHu
///
/// created by hujintao
/// created at 2022/2/18
import 'package:flutter/material.dart';
import 'package:hk_base/adapter.dart';
import 'package:oktoast/oktoast.dart';

///错误提示样式的toast
void hkShowWarnToast(
  String text, {
  duration = 2000,
  GestureTapCallback? onDismiss,
  Color? backgroundColor,
  TextStyle? textStyle,
}) {
  showToast(text,
      backgroundColor: backgroundColor ?? Colors.redAccent.withOpacity(0.9),
      textStyle: textStyle ??
          const TextStyle(
            color: Colors.white,
            fontSize: 16,
          ),
      duration: Duration(milliseconds: duration),
      dismissOtherToast: true);
}

/// 常规Toast
void hkShowToast(String text,
    {duration = 2000,
    GestureTapCallback? onDismiss,
    TextStyle? textStyle,
    Color? backgroundColor}) {
  showToast(text,
      backgroundColor: backgroundColor ?? Colors.black.withOpacity(0.8),
      textStyle: textStyle ??
          const TextStyle(
            color: Colors.white,
            fontSize: 16,
          ),
      duration: Duration(milliseconds: duration),
      dismissOtherToast: true,
      onDismiss: onDismiss);
}

/// 自定义Toast
void hkShowHeartToast(String text,
    {duration = 2000, GestureTapCallback? onDismiss}) {
  showToast(text,
      backgroundColor: const Color(0xffFFF2F4).withOpacity(0.9),
      textStyle: TextStyle(
        color: const Color(0xffFF7E98),
        fontSize: Adapter.setSp(30),
      ),
      duration: Duration(milliseconds: duration),
      dismissOtherToast: true);
}

/// 取消Toast
void hkCancelToast() {
  dismissAllToast();
}
